android.device
Class IccManager

java.lang.Object
  extended by android.device.IccManager

public class IccManager
extends java.lang.Object


Constructor Summary
IccManager()
           
 
Method Summary
 int activate(byte[] pAtr)
          Activate and reset the card
 int apduTransmit(byte[] apdu, int apduLen, byte[] rsp, byte[] sw)
          Transmit APDU to the IC card
 int close()
          Close the slot
 int deactivate()
          Deactivate the card
 int detect()
          check if IC card is inserted
 int open(byte slot, byte CardType, byte Volt)
          Open the IC card for operation
 int setETU(int etuTime)
          Set the ETU.
 int sle4442_changePassword(byte[] passwd)
          Change password.
 int sle4442_readErrorCounter(byte[] errorCount)
          Change password.
 byte[] sle4442_readMainMemory(int addr, int length)
          Read the data stored in main memory for SLE4442
 byte[] sle4442_readProtectionMemory(int address, int len)
          Read SLE4442 card protection bit storage data (4 BYTE). 4 bytes of data read is to save the SLE4442 bits data in storage area.
 int sle4442_reset(byte[] pAtr)
          reset the SLE4442
 int sle4442_verifyPassword(byte[] passwd)
          Comparison of SLE4442 cards, each card after power compared to the card password, otherwise the card data is read-only, you will not be on the card of any write operation.
 int sle4442_writeMainMemory(int addr, byte[] data, int dataLen)
          Write data to the main storage area SLE4442
 int sle4442_writeProtectionMemory(int addr, byte[] data, int dataLen)
          The write protection bit storage area.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IccManager

public IccManager()
Method Detail

open

public int open(byte slot,
                byte CardType,
                byte Volt)
Open the IC card for operation

Parameters:
slot - 0 - IC slot; 1 - PSAM slot
CardType - type: 0x01 - IC card; 0x02 - SLE4442;
Volt - valtage to supply: 0x01 - 3V; 0x02 - 5V; 0x03 - 1.8V;
Returns:
0 if successful;negative number if not successful

close

public int close()
Close the slot

Returns:
0 if successful;negative number if not successful

detect

public int detect()
check if IC card is inserted

Returns:
0 card is detected;negative number if card is not detected

activate

public int activate(byte[] pAtr)
Activate and reset the card

Parameters:
pAtr - to store the returned ATR from the card
Returns:
0 if successful;negative number if not successful

apduTransmit

public int apduTransmit(byte[] apdu,
                        int apduLen,
                        byte[] rsp,
                        byte[] sw)
Transmit APDU to the IC card

Parameters:
apdu - APDU to be sent to the card
apduLenLength - of APDU
rsp - to store the response from the card
sw - to store the returned status bytes
Returns:
length of rsp;returns negative number if function failed

deactivate

public int deactivate()
Deactivate the card

Returns:
0 if successful;negative number if not successful

setETU

public int setETU(int etuTime)
Set the ETU. Default is 372.

Parameters:
etuTime - ETU
Returns:
0 if successful;negative number if not successful

sle4442_reset

public int sle4442_reset(byte[] pAtr)
reset the SLE4442

Parameters:
pAtr - to store the return ATR
Returns:
Length of ATR; Negative number if failed

sle4442_readMainMemory

public byte[] sle4442_readMainMemory(int addr,
                                     int length)
Read the data stored in main memory for SLE4442

Parameters:
addr - The starting address of operation data, the range of the parameters of the SLE4442 card: 0---255.
length - To read the data length, the range of the parameters of the SLE4442 card: 1---256. In addition to ByteAddr and Length and cannot be greater than the actual capacity of the card, otherwise the reader will refuse to execute the command, and returns an error.
Returns:
Returns byte array indicating the store data if successful. Returns null if failed.

sle4442_writeMainMemory

public int sle4442_writeMainMemory(int addr,
                                   byte[] data,
                                   int dataLen)
Write data to the main storage area SLE4442

Parameters:
addr - The starting address of operation data, the range of the parameters of the SLE4442 card: 0---255.
data - The data to be written
Returns:
Returns 0 if successful. Returns -1 if failed.

sle4442_readProtectionMemory

public byte[] sle4442_readProtectionMemory(int address,
                                           int len)
Read SLE4442 card protection bit storage data (4 BYTE). 4 bytes of data read is to save the SLE4442 bits data in storage area. Sequential data bit: low in front, high in the post. Such as: read data: 30 FF 1F F8 from the first byte of 30H can be analyzed as follows: the binary 30H corresponding to the lower four bits: 00110000 to 0 represent the four byte SLE4442 of the card (answer to reset) cannot be changed

Parameters:
address - 0x00- 0xff
Len - Length to read, 4 Bytes: bit31 - read out 32Bytes; bit0 - read out 1Byte; bit* - etc.
Returns:
Returns byte array indicating protected storage data if successful. Returns null if failed.

sle4442_writeProtectionMemory

public int sle4442_writeProtectionMemory(int addr,
                                         byte[] data,
                                         int dataLen)
The write protection bit storage area. Write protection on the 4442 card data (disposable, write protection will not be able to restore). Before the 32BYTE data only for SLE4442 write protect (corresponding to protect a storage area of 32 BIT). This function can be one of a plurality of consecutive bytes protection (up to 32 bytes). According to the write protection properties of SLE4442 card, to a byte write protection must provide the bytes of data at the same time sends the write protection command, consistent data only provides the data and the actual store when really on the specified storage area is write protected.

Parameters:
addr - The starting address of operation data, the range of the parameters of the SLE4442 card: 0---31.
data - Write protect bit data
Returns:
Returns 0 if successful. Returns -1 if failed.

sle4442_verifyPassword

public int sle4442_verifyPassword(byte[] passwd)
Comparison of SLE4442 cards, each card after power compared to the card password, otherwise the card data is read-only, you will not be on the card of any write operation. Secure storage area (except the error counter outside) will not be able to read and write

Parameters:
passwd - The data buffer pointer password, password here to store data migration and card in the password. The first byte of pt corresponding to protected storage (pt+1) corresponding to second byte protected storage (pt+2) corresponding to third byte protected storage
Returns:
Returns 0 if successful. Returns -1 if failed.

sle4442_changePassword

public int sle4442_changePassword(byte[] passwd)
Change password.

Parameters:
passwd - The data buffer point to the new password.
Returns:
Returns 0 if successful. Returns -1 if failed.

sle4442_readErrorCounter

public int sle4442_readErrorCounter(byte[] errorCount)
Change password.

Parameters:
errorCount - The data buffer point to error count, 1Byte.
Returns:
Returns 0 if successful. Returns -1 if failed.